package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootLy;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;
import java.util.Date;

@Getter
@Setter
public class FootLySearchForm extends SearchForm implements Serializable {
	private static final long serialVersionUID = 8090668615941861532L;
	protected String contents;
	protected Date sendTime;

	public Example buildSearchCommond() {
		Example example = new Example(FootLy.class);
		Example.Criteria criteria = example.createCriteria();
		if (!StringUtils.isEmpty(contents)) {
            criteria.andLike("content", "%" + contents.trim() + "%");
		}
		if (sendTime != null) {
            criteria.andEqualTo("sendTime", sendTime);
		}
        criteria.andEqualTo("delFlag", 0);
        example.orderBy("sendTime desc");
		return example;
	}

}
